import http from "@/util/request.js"
const request = (arg) => {
	return http.request(arg)
}
export const checkRegister = (params) => {
	return request({
		url: '/cellphone/existence/check',
		method: 'GET',
		params
	})
}
export const loginByPhone = (params) => {
	return request({
		url: '/login/cellphone',
		method: 'GET',
		params
	})
}
export const register = (params) => {
	return request({
		url: '/register/cellphone',
		method: 'GET',
		params
	})
}
export const initNickName = (params) => {
	return request({
		url: '/activate/init/profile',
		method: 'GET',
		params
	})
}
export const logout = () => {
	return request({
		url: '/logout',
		method: 'GET'
	})
}
export const getLoginStatus = () => {
	return request({
		url: '/login/status',
		method: 'GET'
	})
}
export const getUserDetail = (params) => {
	return request({
		url: '/user/detail',
		method: 'GET',
		params
	})
}
export const getUserDetail_auto = () => {
	return new Promise((resolve, reject) => {
		getLoginStatus().then(res => {
			if (res.code == 200) {
				request({
					url: '/user/detail',
					method: 'GET',
					params: {
						uid: res.profile.userId
					}
				}).then(res1 => {
					resolve(res1)
				}).catach(err => {
					reject(err)
				})
			}
		}).catch(err => {
			if (err.code == 301) {
				reject(err)
			}
		})
	})
}

export const getUserSubcount = () => {
	return request({
		url: '/user/subcount'
	})
}

export const getLikelist = (params) => {
	return request({
		url: '/likelist',
		params
	})
}

export const getUserPlaylist = (params) => {
	return request({
		url: '/user/playlist',
		params
	})
}

export const handleDefaultSign = (params) => {
	return request({
		url: '/daily_signin',
		params
	})
}
